<script setup>
import MetaComponent from "./components/MetaComponent.vue"
import VmFactory from "@/models/VModel.js"
import { vmKey } from "@/models/VModel.js"
import http from "@/utils/request.js"
import { ref, onMounted } from "vue"

const { ns, name, params } = defineProps(["ns", "name", "params"]);

const pageModel = ref({

});

const vm = VmFactory.createVm(pageModel);


function initVm() {
  http.renderView({ ns, name }, (meta) => {
    document.title = meta.title;
    VmFactory.initVm(meta, vm, params);
    pageModel.value = {
      "key": vmKey(vm.ns, vm.name),
      "vm": vm
    }
  });
}

onMounted(() => {
  initVm();
});
</script>
<template>
  <meta-component v-if="pageModel.vm != null" v-bind="pageModel" />
</template>